package priv.ln.compare.comparable;

import org.junit.Test;
import priv.ln.compare.Product;

import java.util.Arrays;

/**
 * ClassName: ComparableTest
 * Package: priv.ln.compare
 * Description:
 *
 * @Author 辣辣
 * @Create 2024/7/28 17:02
 * @Version 1.0
 */
public class ComparableTest {
    @Test
    public void test2(){
        Product[] arr = new Product[5];
        arr[0] = new Product("HuaweiMate50pro",6299);
        arr[1] = new Product("Xiaomi13pro",4999);
        arr[2] = new Product("VivoX90pro",5999);
        arr[3] = new Product("Iphone14ProMax",9999);
        arr[4] = new Product("HonorMagic4",6299);

        Arrays.sort(arr);
        //排序后，遍历
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }

    }
}
